package com.ivo.model;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.ivo.model.Model;

@Entity
@Table (name = "PDM_O_AUTH_TYPE")
public class AuthorityType extends Model {
	
	private static final long serialVersionUID = 51955868399845L;
	
	private String authTypeId;
	private String authTypeName;
	
	private AuthorityType parent;
	private List<AuthorityType> authTypes;
		
	public AuthorityType(){}

	@Id
	@Column(name = "AUTH_TYPE_ID", length=5)
	public String getAuthTypeId() {
		return authTypeId;
	}

	public void setAuthTypeId(String authTypeId) {
		this.authTypeId = authTypeId;
	}

	@Column(name = "AUTH_TYPE_NAME")
	public String getAuthTypeName() {
		return authTypeName;
	}

	public void setAuthTypeName(String authTypeName) {
		this.authTypeName = authTypeName;
	}

	@ManyToOne(cascade = {CascadeType.MERGE}, fetch = FetchType.LAZY)
	@JoinColumn(name = "PARENT_FK", nullable=true)
	public AuthorityType getParent() {
		return parent;
	}

	public void setParent(AuthorityType parent) {
		this.parent = parent;
	}

	@OneToMany(cascade = {CascadeType.MERGE}, targetEntity = AuthorityType.class, mappedBy = "parent", fetch = FetchType.LAZY)
	public List<AuthorityType> getAuthTypes() {
		return authTypes;
	}

	public void setAuthTypes(List<AuthorityType> authTypes) {
		this.authTypes = authTypes;
	}
	
}
